package edu.ucsd.cse110.model;

import java.util.Calendar;

import edu.ucsd.cse110.Utility;

public class Log {
	public final static String[] COLUMNS = { "Id", "Date", "WodId",
			"BodyWeight", "Time", "Rep", "Round", "Notes", "IsInjured" };

	private int mBodyWeight;
	private Calendar mDate;
	private int mId;
	private boolean mIsInjured;
	private String mNotes;
	private int mRep;
	private int mRound;
	private long mTime;
	private int mWodId;

	public Log() {
		Calendar calendar = Calendar.getInstance();
		calendar.clear();

		mDate = calendar;
		mNotes = "";
	}

	public int getBodyWeight() {
		return mBodyWeight;
	}

	public Calendar getDate() {
		return mDate;
	}

	public int getId() {
		return mId;
	}

	public boolean getIsInjured() {
		return mIsInjured;
	}

	/**
	 * @return The time in minutes.
	 */
	public int getMinute() {
		return (int) (mTime / 1000) / 60;
	}

	public String getNotes() {
		return mNotes;
	}

	public int getRep() {
		return mRep;
	}

	public int getRound() {
		return mRound;
	}

	/**
	 * @return The time in seconds.
	 */
	public int getSecond() {
		return (int) (mTime / 1000) % 60;
	}

	public long getTime() {
		return mTime;
	}

	public int getWodId() {
		return mWodId;
	}

	public void setBodyWeight(int bodyWeight) {
		mBodyWeight = bodyWeight;
	}

	public void setDate(Calendar date) {
		mDate = date;
	}

	public void setId(int id) {
		mId = id;
	}

	public void setIsInjured(boolean isInjured) {
		mIsInjured = isInjured;
	}

	public void setNotes(String notes) {
		mNotes = notes;
	}

	public void setRep(int rep) {
		mRep = rep;
	}

	public void setRound(int round) {
		mRound = round;
	}

	/**
	 * @param minutes
	 *            The minutes to set.
	 * @param seconds
	 *            The seconds to set.
	 */
	public void setTime(int minutes, int seconds) {
		mTime = ((minutes * 60) + seconds) * 1000;
	}

	public void setTime(long time) {
		mTime = time;
	}

	public void setWodId(int wodId) {
		mWodId = wodId;
	}

	/**
	 * Returns a string representation of the object.
	 */
	@Override
	public String toString() {
		return String.format("%d, %s, %d, %d, %d, %d, %d, %s, %s", mId,
				Utility.calendarToString(mDate, "EEEE, MMMM dd"), mWodId,
				getMinute(), getSecond(), mRep, mRound, mNotes,
				Boolean.toString(mIsInjured));
	}
}